package cate.game.role.show.msg;

import cate.common.table.d.GDFunc;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgOutput;
import cate.game.client.msg.id.MsgIdBBlog;
import cate.game.display.po.WatchHero;
import cate.game.role.Role;
import cate.game.role.bag.hero.Hero;
import cate.game.role.base.RoleBase;
import cate.game.role.fight.HeroGrid;
import cate.game.role.fight.Position;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;


@ClientMsg(title = "查看其它玩家个人空间 の 返回")
public class OtherRoleBlogResp implements MsgOutput {
	@NoteField("基础数据")
	public RoleBase base;

	@NoteField("展示英雄")
	public List<WatchHero> heros = new ArrayList<>();

	@NoteField("阵型ID")
	public int positionTid;

	@NoteField("协会名字")
	public String guildName;

	public OtherRoleBlogResp() {
	}

	public OtherRoleBlogResp(Role role) {
		base = role.getBase();
		List<String> heroUids = new ArrayList<>();
		Position position = role.getFight().getPosition(GDFunc.ADVENTURE);
		if (position != null) {
			for (HeroGrid grid : position.grids) {
				heroUids.add(grid.uid);
			}
			this.positionTid = position.tid;
		}
		for (String showHeroUid : heroUids) {
			Hero hero = role.getBag().hero.getItem(showHeroUid);
			if (hero != null) {
				heros.add(new WatchHero(role, hero));
			}
		}
		guildName = role.getRes().guild.guildName;
	}

	@Override
	public MsgConfig conf() {
		return MsgIdBBlog.OTHER_ROLE_BLOG_RESP;
	}
}
